Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Jul 9, 2025

Have used "injection" for ICalendarParserTest. Even @InjectMockKs works and injects the mocked ICalPreprocessor.

EventValidator is intentionally not moved yet because it uses the Event data class, which I'd like to get rid of in the new synctools (exception: legacy mappers).

@rfc2822 rfc2822 added the refactoring Quality improvement of existing functions label Jul 9, 2025
@rfc2822 rfc2822 requested a review from Copilot July 9, 2025 11:46
@rfc2822 rfc2822 self-assigned this Jul 9, 2025
@rfc2822 rfc2822 marked this pull request as ready for review July 9, 2025 11:46
@rfc2822 rfc2822 force-pushed the move-validation branch from c253be7 to e30131d Compare July 9, 2025 11:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR relocates the iCalendar validation classes into a new package, converts them from singletons to instantiable classes, and updates all consumers and tests to use injected instances.

  • Moved validation classes under at.bitfire.synctools.icalendar.validation
  • Changed object preprocessors to classes and updated ICalPreprocessor/ICalendarParser for instance-based usage
  • Adapted tests to instantiate and inject preprocessors via MockK

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ICalPreprocessor.kt Converted from object to class, added constructor usage and @VisibleForTesting for stream preprocessors
StreamPreprocessor.kt, FixInvalidUtcOffsetPreprocessor.kt, FixInvalidDayOffsetPreprocessor.kt Updated packages and made preprocessors instantiable
ICalendarParser.kt Added constructor injection for ICalPreprocessor and switched static calls to instance calls
Test files under lib/src/test/kotlin/.../validation/ Updated imports, instantiated classes, and rewrote MockK usage
Task.kt, ICalendar.kt, Event.kt Updated KDoc references to new validation package
Comments suppressed due to low confidence (5)

lib/src/test/kotlin/at/bitfire/synctools/icalendar/validation/FixInvalidUtcOffsetPreprocessorTest.kt:19

  • [nitpick] Test function names use underscores and PascalCase segments; consider using lowerCamelCase (e.g., testFixStringNoOccurrence) to align with Kotlin conventions.
    fun test_FixString_NoOccurrence() {

lib/src/test/kotlin/at/bitfire/synctools/icalendar/validation/FixInvalidUtcOffsetPreprocessorTest.kt:10

  • assertTrue is used in this test but not imported; add import org.junit.Assert.assertTrue to fix compilation.
import org.junit.Assert.assertFalse

lib/src/test/kotlin/at/bitfire/synctools/icalendar/validation/FixInvalidDayOffsetPreprocessorTest.kt:10

  • assertTrue is used below but not imported; add import org.junit.Assert.assertTrue to ensure the tests compile.
import org.junit.Assert.assertFalse

lib/src/test/kotlin/at/bitfire/synctools/icalendar/validation/ICalPreprocessorTest.kt:35

  • You're calling mockkObject on class instances rather than Kotlin objects; use mockkClass, mockkConstructor, or create a spy instance instead.
            mockkObject(it)

lib/src/test/kotlin/at/bitfire/synctools/icalendar/validation/ICalPreprocessorTest.kt:41

  • The verify block wraps a forEach { it.preprocess(any()) }, which executes the loop inside the verification context instead of verifying each call; consider iterating and calling verify { it.preprocess(any()) } for each preprocessor.
        verify {

@rfc2822 rfc2822 requested a review from sunkup July 9, 2025 11:56
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@rfc2822 rfc2822 merged commit 78f1f6f into main Jul 9, 2025
10 checks passed
@rfc2822 rfc2822 deleted the move-validation branch July 9, 2025 13:02
@github-project-automation github-project-automation bot moved this from Todo to Done in DAVx⁵ Releases Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Quality improvement of existing functions

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants